package com.panfeng.xcloud.im.model;

import com.tencentyun.TLSSigAPIv2;
import lombok.Data;
import org.apache.commons.lang.RandomStringUtils;

import java.util.HashMap;
import java.util.Map;

import static com.panfeng.xcloud.im.util.NetUtil.mapToUrlParams;

@Data
public class TLSSigAPIv6 extends TLSSigAPIv2 {

    public final long sdkappid;
    public final String key;
    public final String appAdmin;

    public TLSSigAPIv6(long sdkappid,String key,String appAdmin){
        super(sdkappid,key);
        this.sdkappid = sdkappid;
        this.key = key;
        this.appAdmin = appAdmin;
    }

    public String getUrlParams(){
        Map<String,Object> map = new HashMap<>();
        map.put("sdkappid",this.sdkappid);
        map.put("identifier",this.appAdmin);
        map.put("usersig",this.genSig(this.appAdmin, 180*86400));
        map.put("random", RandomStringUtils.randomAlphanumeric(6));
        map.put("contenttype","json");
        return mapToUrlParams(map);
    }

}
